load("//tools/build_defs/android:fb_xplat_android_cxx_library.bzl", "fb_xplat_android_cxx_library")
load("//tools/build_defs/oss:profilo_defs.bzl", "profilo_cxx_test", "profilo_path")

profilo_cxx_test(
    name = "providers",
    srcs = [
        "TraceProvidersTest.cpp",
    ],
    compiler_flags = [
        "-fexceptions",
        "-frtti",
        "-std=gnu++14",
        "-DLOG_TAG=\"Profilo\"",
    ],
    labels = ["opt-in-sandcastle-sanitized-test"],
    linker_flags = [
        "-ldl",
    ],
    deps = [
        "//xplat/third-party/linker_lib:pthread",
        profilo_path("cpp:providers"),
    ],
)

profilo_cxx_test(
    name = "codegen",
    srcs = [
        "EntryCodegenTest.cpp",
    ],
    compiler_flags = [
        "-fexceptions",
        "-frtti",
        "-std=gnu++14",
        "-DLOG_TAG=\"Profilo\"",
    ],
    labels = ["opt-in-sandcastle-sanitized-test"],
    deps = [
        profilo_path("cpp/generated:cpp"),
        profilo_path("cpp/writer:print_visitor"),
    ],
)

profilo_cxx_test(
    name = "delta_visitor",
    srcs = [
        "DeltaEncodingVisitorTest.cpp",
    ],
    compiler_flags = [
        "-fexceptions",
        "-frtti",
        "-std=gnu++14",
        "-DLOG_TAG=\"Profilo\"",
    ],
    labels = ["opt-in-sandcastle-sanitized-test"],
    deps = [
        "//xplat/third-party/linker_lib:pthread",
        profilo_path("cpp/writer:delta_visitor"),
        profilo_path("cpp/writer:print_visitor"),
    ],
)

profilo_cxx_test(
    name = "stack_visitor",
    srcs = [
        "StackTraceInvertingVisitorTest.cpp",
    ],
    compiler_flags = [
        "-fexceptions",
        "-frtti",
        "-std=gnu++14",
        "-DLOG_TAG=\"Profilo\"",
    ],
    labels = ["opt-in-sandcastle-sanitized-test"],
    deps = [
        "//xplat/third-party/linker_lib:pthread",
        profilo_path("cpp/writer:print_visitor"),
        profilo_path("cpp/writer:stack_visitor"),
    ],
)

profilo_cxx_test(
    name = "packet_logger",
    srcs = [
        "PacketLoggerTest.cpp",
    ],
    compiler_flags = [
        "-fexceptions",
        "-frtti",
        "-std=gnu++14",
        "-DLOG_TAG=\"Profilo\"",
    ],
    labels = ["opt-in-sandcastle-sanitized-test"],
    deps = [
        "//xplat/third-party/gmock:gmock",
        "//xplat/third-party/linker_lib:pthread",
        profilo_path("cpp/mmapbuf:buffer"),
        profilo_path("cpp/writer:packet_reassembler"),
    ],
)

profilo_cxx_test(
    name = "trace_writer",
    srcs = [
        "TraceWriterTest.cpp",
    ],
    compiler_flags = [
        "-fexceptions",
        "-frtti",
        "-std=gnu++14",
        "-DLOG_TAG=\"Profilo\"",
    ],
    labels = ["opt-in-sandcastle-sanitized-test"],
    linker_flags = [
        "-pthread",
    ],
    deps = [
        "//xplat/folly:experimental_test_util",
        "//xplat/third-party/gmock:gmock",
        profilo_path("cpp/writer:writer"),
    ],
)

profilo_cxx_test(
    name = "ring_buffer",
    srcs = [
        "LockFreeRingBufferTest.cpp",
    ],
    compiler_flags = [
        "-fexceptions",
        "-frtti",
        "-std=gnu++14",
        "-DLOG_TAG=\"Profilo\"",
    ],
    labels = ["opt-in-sandcastle-sanitized-test"],
    linker_flags = [
        "-ldl",
    ],
    deps = [
        "//xplat/folly:experimental_test_util",
        "//xplat/third-party/linker_lib:pthread",
        profilo_path("deps/zstr:zstr"),
        profilo_path("cpp/logger/lfrb:lfrb"),
        profilo_path("cpp/util:util"),
    ],
)

fb_xplat_android_cxx_library(
    name = "test_sequencer",
    srcs = [
        "TestSequencer.cpp",
    ],
    header_namespace = "profilo/test",
    exported_headers = [
        "TestSequencer.h",
    ],
    compiler_flags = [
        "-fexceptions",
        "-frtti",
        "-std=gnu++14",
        "-DLOG_TAG=\"Profilo\"",
    ],
)

profilo_cxx_test(
    name = "sampling_profiler",
    srcs = [
        "SamplingProfilerTest.cpp",
    ],
    compiler_flags = [
        "-fexceptions",
        "-frtti",
        "-std=gnu++14",
        "-DLOG_TAG=\"Profilo\"",
    ],
    labels = ["opt-in-sandcastle-sanitized-test"],
    linker_flags = [
        "-ldl",
        "-lrt",
    ],
    deps = [
        ":test_sequencer",
        profilo_path("deps/fb:fb"),
        profilo_path("deps/sigmux:phaser"),
        profilo_path("cpp/profiler:profiler"),
        profilo_path("cpp/util:util"),
    ],
)

profilo_cxx_test(
    name = "perfevents",
    srcs = [
        "FileBackedMappingsTest.cpp",
    ],
    compiler_flags = [
        "-fexceptions",
        "-frtti",
        "-std=gnu++14",
        "-DLOG_TAG=\"Profilo\"",
    ],
    labels = ["opt-in-sandcastle-sanitized-test"],
    linker_flags = [
        "-ldl",
    ],
    deps = [
        profilo_path("cpp/perfevents:file_backed_mappings_list"),
    ],
)
